import request from '@/utils/request'

/**
 * 查询运输订单列表
 * @param {Object} query - 查询参数，包括分页、筛选条件等
 * @returns {Promise} - 返回运输订单数据和分页信息
 */
export function listOperatorTransport(query) {
    return request({
        url: '/delivery/operatorTransportOrder/list',
        method: 'get',
        params: query,
    });
}

/**
 * 新增运输订单
 * @param {Object} data - 运输订单信息
 * @returns {Promise} - 返回新增结果
 */
export function addOperatorTransport(data) {
    return request({
        url: '/delivery/operatorTransportOrder/add',
        method: 'post',
        data,
    });
}

/**
 * 更新运输订单
 * @param {Object} data - 运输订单信息
 * @param {String} approach - 变更方式
 * @returns {Promise} - 返回更新结果
 */
export function updateOperatorTransport(data, approach) {
    return request({
        url: '/delivery/operatorTransportOrder/update',
        method: 'put',
        params: { approach },
        data,
    });
}

/**
 * 删除运输订单
 * @param {String} trackingNumber - 运输订单号
 * @returns {Promise} - 返回删除结果
 */
export function deleteOperatorTransport(trackingNumber) {
    return request({
        url: `/delivery/operatorTransportOrder/delete`,
        method: 'delete',
        params: { trackingNumber },
    });
}

/**
 * 获取运输订单详情
 * @param {String} trackingNumber - 运输订单号
 * @returns {Promise} - 返回运输订单详情
 */
export function getOperatorTransportDetail(trackingNumber) {
    return request({
        url: `/delivery/operatorTransportOrder/details`,
        method: 'get',
        params: { trackingNumber },
    });
}
/**
 * 添加运输订单明细
 * @param {Object} data - 运输订单明细信息
 * @returns {Promise} - 返回添加结果
 */
export function addOperatorTransportDetail(data) {
    return request({
        url: '/delivery/operatorTransportDetail/addDetail',
        method: 'post',
        data,
    });
}

/**
 * 确认运输订单
 * @param {String} trackingNumber - 运输订单号
 * @returns {Promise} - 返回确认结果
 */
export function confirmOperatorTransport(trackingNumber) {
    return request({
        url: `/delivery/operatorTransportOrder/confirm`,
        method: 'put',
        params: { trackingNumber },
    });
}

